package org.seven.jrdp.web.t;

import java.util.List;

import org.seven.jrdp.biz.t.model.TKh;
import org.seven.jrdp.biz.t.service.TKhService;
import org.seven.jrdp.commons.model.Option;
import org.seven.jrdp.commons.model.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@RestController
@RequestMapping("/mgt/t/kh")
public class TKhController {
	@Autowired
	private TKhService tKhService;

	@GetMapping("/{view}")
	public ModelAndView view(@PathVariable String view) {
		return new ModelAndView("mgt/t/kh/kh_" + view);
	}

	@PostMapping("/find")
	public List<TKh> find() {
		List<TKh> list = tKhService.find();
		return list;
	}

	@RequestMapping("/get")
	public TKh get(String id) {
		TKh tKh = tKhService.get(id);
		return tKh;
	}

	@PostMapping("/insert")
	public Result insert(TKh tKh) {
		tKhService.insert(tKh);
		return Result.SUCCESS;
	}

	@PostMapping("/update")
	public Result update(TKh tKh) {
		tKhService.update(tKh);
		return Result.SUCCESS;
	}

	@PostMapping("/delete")
	public Result delete(String id) {
		tKhService.delete(id);
		return Result.SUCCESS;
	}

	@RequestMapping("/option")
	public List<Option> option() {
		return tKhService.getOption();
	}
}